package com.pencilisland.pay.app.mp.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pencilisland.pay.api.bean.mp.app.MessageRequest;
import com.pencilisland.pay.api.bean.mp.app.MessageResponse;
import com.pencilisland.pay.app.mp.service.MPService;
import com.pencilisland.pay.app.util.RequestUtil;

/**
 * 报文信息处理器
 * 
 * @author breeze
 *
 */
@Controller
@RequestMapping(value = "/app/mp")
public class MPController {
	Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	MPService mpService;
	
	@RequestMapping(method=RequestMethod.POST)
	@ResponseBody
	public MessageResponse receiveMessage(@RequestBody MessageRequest request,HttpServletRequest req) {
		request.setIp(RequestUtil.getRemoteHost(req));
		MessageResponse response = mpService.receive(request);
		return response;
	}

}
